<?php
/**
 * Mailbox Password Change Popup
 * 
 */
use Fox\Html\Input;
use Fox\Generator;
use Orx\Mailer\Messages;
use Orx\User\MailBox;
use Fox\Popup\Modify;

$pop = new Modify('pPassword',
				MailBox::className(),
				null,
				array(Messages::BUNDLE,Messages::CHANGE_YOUR_PASSWORD),
				null,
				array(Messages::BUNDLE,Messages::YOUR_NEW_PASSWORD_HAS_BEEN_SAVED),
				null,
				Generator::useFunction(function($objectToModify){
					if($objectToModify->new_password != $objectToModify->password_confirmation) {
						throw new \Exception(Msg(Messages::BUNDLE,Messages::SORRY_BUT_PASSWORD_AND_CONFIRMATION_SHOULD_BE_EQUAL));
					}
					$objectToModify->password = $objectToModify->new_password;
					$objectToModify->password = \Fox\Utilities::crypt($objectToModify->new_password,_APPLICATION_PRIVATE_KEY_);
					return $objectToModify->update();
					
				})
				);
$pop->block()->add(new Input('new_password',true))
			->inputType('password')
			->label(Msg(Messages::BUNDLE,Messages::NEW_PASSWORD))
			->parentObject()
			->add(new Input('password_confirmation',true))
			->inputType('password')
			->label(Msg(Messages::BUNDLE,Messages::CONFIRM_PASSWORD));
return $pop->display();